﻿using System;
using UnityEngine.UIElements;

namespace winS.UnityEditor.ProcessEditor
{
    public class InputPort : Port
    {
        public sealed override PortType portType => PortType.Input;

        public InputPort(StepNode stepNode) : base(stepNode)
        {
            name = "输入端口";
            style.marginLeft = 4f;
            style.alignSelf = Align.FlexStart;

            label.text = "输入";
        }

        public override void Connect(Connectionline connectionline)
        {
            connectedPortList.Add(connectionline.outputPort);
            connectedNodeList.Add(connectionline.outputPort.node);
            base.Connect(connectionline);
        }
        public override void Disconnect(Connectionline connectionline)
        {
            if (!connectedPortList.Remove(connectionline.outputPort)) throw new Exception("端口断开异常");
            if (!connectedNodeList.Remove(connectionline.outputPort.node)) throw new Exception("节点断开异常");
            base.Disconnect(connectionline);
        }
    }
}